<template>
<div class="container">
    <span class="list">课程列表</span>
    <div class="big">

        <div class="courseList" v-for="item in arr" :key="item.id">
            <div class="buju">
                <div class="shang">
                    <span>ID:{{item.id}}</span>
                    <input type="checkbox" :value="item.id" @click="checkfun(item.id)">
                </div>

                <div class="L-img">
                    
                    <img :src="imgPort" alt="" class="im">
                </div>
                
                <div class="neir">
                        <span class="c">幼儿英语入门课程</span>
                        <p class="p">报名费:{{item.pay}}元</p>
                        <p class="p">销量:{{item.num}}</p>
                        <p class="p">上传人: {{item.name}}</p>
                        <p class="p">上传时间:{{item.time}}</p>
                </div>
                
                <div class="btn">
                    <el-button type="primary" @click="showDialog(item)"><i class="el-icon-edit"></i>编辑</el-button>
                    <el-button type="info" @click="handeldel(item.id)"><i class="el-icon-delete"></i>删除</el-button>
                </div>
                    
            </div>
        </div>
    </div>
</div>
 
</template>

<script>
var ids = ''
import {delHomeApi, updelHomeApi} from '../../../api/homeApi'

   import imgPort from '../../../assets/img/houtaiimg/kecheng-picture01.png'
export default {
       props:['arr'] ,
    
    data() {
      return {
        //   checkbox:[],
          imgPort:imgPort
      };
    },
    methods: {
        checkfun (id) {
            ids += id + ','
            console.log(ids)
           this.$parent.ids = ids
        },
        // 编辑事件
        showDialog(val){  //添加第一步 控制dialog显示和隐藏
        this.$emit('parentIsshow',val)
        console.log(val)
        },
        // 删除事件
      handeldel(id){
             console.log(id)
             delHomeApi({id:id}).then(res=>{
                if(res.code==200){
                    // 请求成功刷新表格
                    // 调用父组件中的内容
                    this.$emit('parentDel')
                    console.log("删除成功")
                }
             })

      }
    }
}
</script>

<style lang='less' scoped>

.container{
   
    width: 100%;
    padding-top: 20px;
   
    .list{
        width: 100%;
        height: 10px;
        font-weight: 900;
        margin-top: 200px;
        margin-left: 20px;
    
    }
    .big{
        display: flex;
        justify-content: space-around;
        // align-items: center;
        flex-wrap: wrap;
        .courseList{
            width: 23%;
            height: 360px;
            background: white;
            padding: 20px 20px;
            box-sizing: border-box;
            margin: 10px;
        }
        .buju{
            margin: 0 auto;
            // background: yellow;
            box-sizing: border-box;
            display: flex;
           flex-direction: column;
           justify-content: flex-start;
           align-items: flex-start;
            .shang{
                width: 100%;
            display: flex;
            justify-content:space-between;
            align-items: center;
            margin: 0 auto;
            font-weight: 900;
            margin-bottom:10px ;
            }
            .neir{
                display: flex;
                // justify-content: flex-start;
                flex-direction: column;
                .c{
                    font-weight: 900;
                }
                .p{
                    margin: 3px;
                }
            }
            .btn{
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-left: 50px;
                margin-top:5px ;
            }
            .L-img{
                width: 100%;
                height: 150px;
                margin: 0 auto;
                margin-bottom: 10px;
                background: pink;
                .im{
                    width: 100%;
                    height: 100%;
                }
            }
        }
        
    }
}
</style>
